package cn.edu.hatu.bookshop.service;

import cn.edu.hatu.bookshop.dao.CartMapper;
import cn.edu.hatu.bookshop.entity.Cart;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CartService {
    private CartMapper cartMapper;
    @Autowired
    public void setCartMapper(CartMapper cartMapper) {
        this.cartMapper = cartMapper;
    }
    public List<Cart> getAll(){
        List<Cart> carts = cartMapper.getAll();
        return carts;
    }
    public List<Cart> findByCustomerId(int customerId){
        List<Cart> carts = cartMapper.findByCustomerId(customerId);
        return carts;
    }
    public Cart findByCartId(int cartId){
        Cart cart = cartMapper.findByCartId(cartId);
        return cart;
    }
    public void addCart(Cart cart){
        cartMapper.addCart(cart);
    }
    public void delByCartId(int cartId){
        cartMapper.delByCartId(cartId);
    }

}
